﻿// Copyright © Microsoft Corporation.  All Rights Reserved.
// This code released under the terms of the 
// Microsoft Public License (MS-PL, http://opensource.org/licenses/ms-pl.html.)

using System.ComponentModel;
using System.Windows;
using System.Windows.Controls;

namespace TheOliver.Controls
{
    public class GoToStateAction : System.Windows.Interactivity.TargetedTriggerAction<FrameworkElement>
    {
        #region Property to Expose
        [Category("VSM Properties")]
        public string StateName
        {
            get { return (string)GetValue(StateNameProperty); }
            set { SetValue(StateNameProperty, value); }
        }

        public static readonly DependencyProperty StateNameProperty = DependencyProperty.Register("State Name", typeof(string), typeof(GoToStateAction), new PropertyMetadata(StateNamePropertyChanged));

        #endregion

        protected override void Invoke(object o)
        {
            VisualStateManager.GoToState(Application.Current.RootVisual as Control, StateName, true);
        }

        private static void StateNamePropertyChanged(DependencyObject obj, DependencyPropertyChangedEventArgs e)
        {
            // Do something
        }

    }
}
